﻿#pragma once
#include <QObject>
class QStringView;
class QJsonObject;
class PluginAction;

class Plugin : public QObject
{
	Q_OBJECT
public:
    Plugin(PluginAction* pa) : m_pluginAction(pa){};
	virtual ~Plugin() = default;
	Plugin(Plugin const&) = delete;
	Plugin& operator=(Plugin const&) = delete;
	virtual QStringView name() const = 0;
	virtual bool load(QString const& cfgFile = QString()) = 0;
	virtual void logsEvent(QJsonObject const& logsObj) = 0;
	virtual void sensorsEvent(QJsonObject const& valuesObj) = 0;
    virtual QStringList subTopic() const = 0;
    virtual void handleMessage(QStringView topic, QByteArray payload) = 0;
    virtual QStringList commands() const = 0;
signals:
    void loadFinished(QString);                 //在加载完成插件后必须发送loadFinished信号
	void errors(QString, QString = QString());
protected:
    PluginAction* m_pluginAction = nullptr;
};